import sqlite3
import time
import cPickle
import ajc

db = sqlite3.connect(':memory:')
db.execute("CREATE TABLE IF NOT EXISTS my_table (fid INTEGER, key TEXT, value NONE, PRIMARY KEY (fid, key))")
db.execute("CREATE INDEX IF NOT EXISTS my_table_pin ON my_table (value)")

N = 10000
i = N + 1
j = 0
db.execute('INSERT INTO my_table (fid,key,value) VALUES (?,?,?)', (i, str(i) + str(j), 2903,))
j = 1
db.execute('INSERT INTO my_table (fid,key,value) VALUES (?,?,?)', (i, str(i) + str(j), 'FOOBARBAZ',))

for i in range(i):
    for j,value in enumerate([1.0, 2.0, 2, -1, 3, -34, '1.0', '1', 1, 'HELLO', 'GOODBYE', None, None, 234, 234, 234, 1.234, -234234, 2323, 'A', 'B']):
        db.execute('INSERT INTO my_table (fid,key,value) VALUES (?,?,?)', (i, str(i) + str(j), value,))

i = N+2
j = 0
db.execute('INSERT INTO my_table (fid,key,value) VALUES (?,?,?)', (i, str(i) + str(j), 2903,))
j = 1
db.execute('INSERT INTO my_table (fid,key,value) VALUES (?,?,?)', (i, str(i) + str(j), 'FOOBARBAZ',))
        
db.commit()
    
print 'HELLO' < 10
ajc.util.time_start(msg = 'Query')
for row in db.execute('SELECT value FROM my_table WHERE value = 2903'):
    assert row[0].__class__ is int
    #print row[0]
    #assert row[0].__class__ is unicode

ajc.util.time_stop()
        